/*
** format.c for format in /home/dieng_e
** 
** Made by el-hadji-malick-ndour dieng
** Login   <dieng_e@epitech.net>
** 
** Started on  Sat Jul  9 18:29:27 2011 el-hadji-malick-ndour dieng
** Last update Sun Jul 10 23:40:34 2011 vincent ricard
*/

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include "parser.h"
#include "types.h"

void	send_taille_map(int socket, t_server_params *p)
{
  char *ptr;

  ptr = malloc(sizeof(int) * 3);
  sprintf(ptr, "%d\n%d %d\n", socket, p->x, p->y);
  write(socket, ptr, strlen(ptr));
  free(ptr);
}

char	*int_to_char(int socket)
{
  char *ptr;

  ptr = malloc(sizeof(int) * 3);
  if (ptr == NULL)
    return NULL;
  sprintf(ptr, "sgt %d\n", socket);

  return (ptr);
}

void	format_msz(T_env *e, t_server_params *p)
{
  char *ptr;

  ptr = malloc(sizeof(int) * 3);
  sprintf(ptr, "msz %d %d\n", p->x, p->y);
  if (write(e->i, ptr, strlen(ptr)))
    printf("%d: Sending Message  \"msz %d %d\" to %d\n",
	current_time(), p->x, p->y, e->i);
  free(ptr);
}
void	format_sgt(T_env *e, t_server_params *p)
{
  if (write(e->i, int_to_char(p->time), strlen(int_to_char(p->time))))
    printf("%d: Sending Message \"%s\" to %d",
	   current_time(), int_to_char(p->time));
}
void	format_tna(T_env *e, t_server_params *p)
{
  display_team(e->list_team, 0 , e);
}

void	format_mct(T_env *e, t_server_params *p)
{
  printf("mct func\n");
}

void	format_ppo(T_env *e, t_server_params *p)
{
  printf("ppo func\n");
}
void	format_plv(T_env *e, t_server_params *p)
{
  printf("plv func\n");
}
void	format_pln(T_env *e, t_server_params *p)
{
  printf("pln func\n");
}

void	format_bct(T_env *e, t_server_params *p)
{
  if (write(e->i, "bct 0 0 0 1 1 0 0 2 0\n", 22))
    printf("%d: Sending Message  from to %d\n", current_time(),  e->i);
}
void	format_sst(T_env *e, t_server_params *p)
{
  printf("sst func --> \n");
}
